-- CALC_PILGRIM_BONUS

-- 计算朝圣者残骸的奖励
-- @param user  玩家对象
return function(user)
    local bonus = {};
    local rand = DungeonM.getRandSeed("CALC_PILGRIM_BONUS") % 100;
    local amount = 1 + DungeonM.getRandSeed("CALC_PILGRIM_BONUS") % 2;

    -- 元素结晶
    if rand < 10 then
        bonus = { { 1, 7017, amount, }, };
    elseif rand < 20 then
        bonus = { { 1, 7018, amount, }, };
    elseif rand < 30 then
        bonus = { { 1, 7019, amount, }, };
    elseif rand < 40 then
        bonus = { { 1, 7020, amount, }, };
    elseif rand < 80 then
        -- 随机1~2阶魔法卷轴1~3个
        for i = 1, amount do
            local randSeed = DungeonM.getRandSeed("CALC_PILGRIM_BONUS");
            local rank = randSeed % 2 + 1;

            -- 该阶位所有的卷轴
            local spells = SpellM.getSpellByRank(rank);

            local classId = spells[randSeed % #spells + 1];

            table.insert(bonus, { 1, classId, 1, });
        end
    else
        -- 随机【学徒套装】或【法师套装】装备1个
        local randSeed = DungeonM.getRandSeed("CALC_PILGRIM_BONUS");
        local suitId;

        if randSeed % 2 == 1 then
            suitId = 6;     -- 学徒
        else
            suitId = 7;     -- 法师
        end

        local equips = SuitM.query(suitId, "active");
        local classId = equips[randSeed % #equips + 1];

        table.insert(bonus, { 1, classId, 1, });
    end

    return {
        ["bonus"] = bonus,
    };
end
